<style>   
    .ac_results {
        padding: 0px;
        border: 1px solid black;
        background-color: white;
        overflow: hidden;
        z-index: 99999;
        color: black;
        /*        width: 600px;*/
    }

    .ac_results ul {
        width: 100%;
        list-style-position: outside;
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .ac_results li {
        margin: 0px;
        padding: 2px 5px;
        cursor: default;
        display: block;
        /* 
        if width will be 100% horizontal scrollbar will apear 
        when scroll mode will be used
        */
        /*        width: 900px;*/
        font: menu;
        font-size: 12px;
        /* 
        it is very important, if line-height not setted or setted 
        in relative units scroll will be broken in firefox
        */
        line-height: 16px;
        overflow: hidden;
    }

    .ac_loading {
        background: white url('indicator.gif') right center no-repeat;
    }

    .ac_odd {
        background-color: #eee;
    }

    .ac_over {
        background-color: #0A246A;
        color: white;
    }
</style>

<div class="page_title">
    <span class="title_icon"><span class="blocks_images"></span></span>
    <h3>Pacientes</h3>    
</div>
<div id="content">
    <div class="grid_container">

        <div class="grid_12">
            <div class="widget_wrap">
                <div class="widget_top">
                    <span class="h_icon blocks_images"></span>
                    <h6>Acciones</h6>
                </div>
                <?php $grupo = $this->Session->read('Auth.User.group_id'); ?>
                <?php if ($grupo != 5 || $grupo != 3): ?>
                    <div class="widget_content">
                        <div class="all_buttons">
                            <div class="btn_40_blue ucase">
                                <a href="#"><span class="icon finished_work_sl"></span><span>NUEVO LABORATORIO &nbsp;&nbsp;&nbsp; </span></a>
                            </div>

                        </div>
                    </div>
                <?php endif; ?>
            </div>
        </div>

        <span class="clear"></span>
        <?php //debug($ficha)?>

        <span class="clear"></span>

        <div class="grid_12">
            <div class="widget_wrap">
                <div class="widget_top">
                    <span class="h_icon blocks_images"></span>
                    <h6>Datos para la consulta</h6>
                </div>
                <div class="widget_content">                    
                    <div class=" page_content">
                        <div class="grid_12 invoice_num">
                            <?php
                            $verificaColor = $alertaPaciente['Alerta']['color'];
                            //debug($color);
                            switch ($verificaColor) {
                                case "rojo":
                                    $color = "#D66";
                                    break;
                                case "amarillo":
                                    $color = "#FFFFAA";
                                    break;
                                case "verde":
                                    $color = "#008000";
                                    break;
                                case "blanco":
                                    $color = "#FFF";
                                    break;
                                default:
                                    echo "No existe la alerta";
                            }
                            ?>
                            <span style="background: <?php echo $color; ?>">
                                COLOR DE ALERTA DEL PACIENTE
                            </span>
                        </div>
                        <span class="clear"></span>
                        <div class="invoice_container">
                            
                            <div class="grid_6 invoice_num">
                                <span>Motivo de consulta: <?php echo $ficha['Trauma']['nombre'] ?></span>
                            </div>
                            <div class="grid_2 invoice_num">
                                <span>Edad: <?php echo $edad ?></span>
                            </div>
                            <span class="clear"></span>
                            <div class="grid_12">
                                <table class="wtbl_list">

                                </table>
                            </div>
                            <span class="clear"></span>
                            <div class="grid_2 invoice_to">
                                <ul>
                                    <li>
                                        <strong><span>Nombres</span></strong>
                                        <strong><span>Apellidos</span></strong> 
                                        <strong><span>Fecha consulta</span></strong>
                                        <strong><span>Hora consulta</span></strong> 
                                    </li>
                                </ul>
                            </div>
                            <div class="grid_2 invoice_from">
                                <ul>
                                    <li>

                                        <span>
                                            <?php echo $ficha['Paciente']['nombres'] ?>
                                        </span>
                                        <span>
                                            <?php echo $ficha['Paciente']['ap_paterno'] . ' ' . $ficha['Paciente']['ap_materno'] ?>
                                        </span>

                                        <span>
                                            <?php echo $ficha['Consultasexterna']['fecha'] ?>
                                        </span>
                                        <span>
                                            <?php echo $ficha['Consultasexterna']['hora'] ?>
                                        </span>
                                    </li>
                                </ul>
                            </div>
                            <div class="grid_2 invoice_to">
                                <ul>
                                    <li>
                                        <strong><span>Seguro</span></strong>
                                        <strong><span>Curso</span></strong>
                                    </li>
                                </ul>
                            </div>
                            <div class="grid_2 invoice_from">
                                <ul>
                                    <li>

                                        <span>
                                            <?php echo $seguro['Seguro']['nombre'] ?>
                                        </span>
                                        <span>
                                            <?php echo $seguro['SegurosPaciente']['curso'] ?>
                                        </span>
                                    </li>
                                </ul>
                            </div>
                            <?php if ($detallePaciente['Paciente']['lugar'] == 'provincia'): ?>
                                <div class="grid_2 invoice_to">
                                    <ul>
                                        <li>
                                            <strong><span>Alcaldia/localidad:</span></strong>
                                            <strong><span>Celular:</span></strong>
                                            <strong><span>Departamento:</span></strong>
                                            <strong><span>Provincia:</span></strong>  
                                        </li>
                                    </ul>
                                </div>
                                <div class="grid_2 invoice_from">
                                    <ul>
                                        <li>
                                            <span>
                                                <?php echo $detallePaciente['Paciente']['alcaldia'] ?>/<?php echo $detallePaciente['Paciente']['localidad'] ?>
                                            </span>
                                            <span><?php echo $detallePaciente['Paciente']['celular_p'] ?></span>
                                            <span><?php echo $detallePaciente['Departamentoprovincia']['nombre'] ?></span>                                
                                            <span><?php echo $detallePaciente['Provinciaprovincia']['nombre'] ?></span>
                                        </li>
                                    </ul>
                                </div>
                            <?php else: ?>
                                <div class="grid_2 invoice_to">
                                    <ul>
                                        <li>
                                            <strong><span>Direccion:</span></strong>
                                            <strong><span>Telefono:</span></strong>  
                                            <strong><span>Celular:</span></strong>
                                            <strong><span>Departamento:</span></strong>
                                            <strong><span>Provincia:</span></strong> 
                                            <strong><span>Email:</span></strong>
                                        </li>
                                    </ul>
                                </div>
                                <div class="grid_2 invoice_from">
                                    <ul>
                                        <li>
                                            <span><?php echo $detallePaciente['Paciente']['direccion'] ?></span>
                                            <span><?php echo $detallePaciente['Paciente']['telefono'] ?></span>
                                            <span><?php echo $detallePaciente['Paciente']['celular'] ?></span>
                                            <span><?php echo $detallePaciente['Departamento']['nombre'] ?></span>
                                            <span><?php echo $detallePaciente['Provincia']['nombre'] ?></span>
                                            <span><?php echo $detallePaciente['Paciente']['correo'] ?></span>
                                        </li>
                                    </ul>
                                </div>
                            <?php endif; ?>

                            <span class="clear"></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <span class="clear"></span>

        <div class="grid_12">
            <div class="widget_wrap">
                <div class="widget_top">
                    <span class="h_icon blocks_images"></span>
                    <h6>Resultados de laboratorios</h6>
                </div>
                <div class="widget_content">
                    <div class=" page_content">
                        <div class="invoice_container">

                            <div id="cargaLaboratorios">
                                <?php echo $this->Form->create('Examene', array('action' => 'examenlaboratorio')) ?>
                                <div class="stat_block">
                                <table>
                                    <thead>
                                        <tr>
                                            <th>Examen</th>
                                            <th>Dato</th>
                                            <th>Observaciones</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php $i = 0;
                                    $j = 1; ?>
                                        <?php foreach ($laboratoriosDelPaciente as $lp): ?>
                                            <?php echo $this->Form->hidden("Examenespaciente.$i.subclaseslaboratorio_id", array('value' => $lp['Laboratoriospaciente']['subclaseslaboratorio_id'])) ?>
                                            <?php echo $this->Form->hidden("Examenespaciente.$i.laboratorio_id", array('value' => $lp['Laboratoriospaciente']['laboratorio_id'])) ?>
                                            <?php echo $this->Form->hidden("Examenespaciente.$i.paciente_id", array('value' => $lp['Laboratoriospaciente']['paciente_id'])) ?>
                                            <?php echo $this->Form->hidden("Examenespaciente.$i.consultasexterna_id", array('value' => $lp['Laboratoriospaciente']['consultasexterna_id'])) ?>
                                            <?php echo $this->Form->hidden("Examenespaciente.$i.user_id", array('value' => $this->Session->read('Auth.User.id'))) ?>
                                            <?php if ($lp['Laboratoriospaciente']['laboratorio_id'] == null): ?>
                                                <tr class="<?php echo $estilo = fmod($j, 2) ? "tr_even" : "tr_odd"; ?>">
                                                    <td colspan="3"><?php echo $lp['Subclaseslaboratorio']['nombre']; ?></td>
                                                 </tr>
                                                <?php else: ?>
                                                <tr class="<?php echo $estilo = fmod($j, 2) ? "tr_even" : "tr_odd"; ?>">
                                                    <td>
                                                    <?php echo $lp['Laboratorio']['nombre']; ?>
                                                    </td>
                                                    <td>
                                                    <?php echo $this->Form->text("Examenespaciente.$i.dato", array('class' => 'validate number')) ?>
                                                    </td>
                                                    <td>
                                                        <?php echo $this->Form->textarea("Examenespaciente.$i.observaciones", array('class' => 'validate number')) ?>
                                                    </td>
                                                </tr>
                                            <?php endif; ?>
                                            <?php $j++; ?>
                                           <?php $i++; ?>
                                        <?php endforeach; ?>
                                    </tbody>
                                </table>  
                                    </div>
                            <?php
                            $options = array(
                                'Value' => 'Guardar resultados',
                                'class' => 'btn_small btn_blue'
                            );
                            echo $this->Form->end($options);
                            
                            ?>
                            </div>
                            <span class="clear"></span> 
                            <br />
                            <!--<button type="reset" class="btn_small btn_blue" id="btNuevoLaboratorio">                              
                                <span>Nuevo Laboratorio</span>
                            </button>-->

                            <div id="muestraNuevoLaboratorio" style="display: none;">
<?php //echo $this->Form->create('Paciente', array('id' => "form103", 'class' => "form_container left_label valid_tip", 'action' => 'registralab'))  ?>
                                <?php
                                echo $this->Ajax->form(array('type' => 'post',
                                    'options' => array(
                                        'model' => 'Pacientes',
                                        'update' => 'cargaLaboratorios',
                                        'url' => array(
                                            'controller' => 'Pacientes',
                                            'action' => 'ajaxregistralab'
                                        ),
                                    )
                                ));
                                ?>
                                <ul>
                                    <li>
                                        <div class="form_grid_12">
                                        <?php
                                            $idPacienteLab = $detallePaciente['Paciente']['id'];
                                            ?>
                                            <?php echo $this->Form->hidden('paciente_id', array('value' => $idPacienteLab)); ?>
                                            <?php echo $this->Form->hidden('consultasexterna_id', array('value' => $idConsultaExterna)); ?>
                                            <select data-placeholder="Seleccione la Categoria..." class="chzn-select full" name="data[Pacientes][cagtegoria_id]" tabindex="4" id="clasesLab" style="width: 300px;">
                                                <option value="0" selected="selected">Seleccione una Categoria</option>
                                                    <?php foreach ($clasesDeLaboratorios as $cdl): ?>
                                                    <option value="<?php echo $cdl['Claseslaboratorio']['id'] ?>">
                                                    <?php echo $cdl['Claseslaboratorio']['nombre'] ?>
                                                    </option>
                                                    <?php endforeach; ?>
                                            </select>
                                        </div>
                                        <p>&nbsp;</p>
                                    </li>
                                    <li>
                                        <div id="cargaSubLaboratorios">
                                            <h1>&nbsp;</h1>                                    
                                            <h1>&nbsp;</h1>  
                                            <h1>&nbsp;</h1>                                    
                                            <h1>&nbsp;</h1>  
                                            <h1>&nbsp;</h1>                                    
                                            <h1>&nbsp;</h1>  
                                            <h1>&nbsp;</h1>                                    
                                            <h1>&nbsp;</h1>                                             
                                        </div>
                                    </li>
                                </ul>

                                </form>
                                <script>
                                    $(document).ready(function() {
                                        $('#clasesLab').change(function() {
                                            $('#cargaSubLaboratorios').load("<?php echo $this->Html->url(array('controller' => 'Laboratorios', 'action' => 'ajaxsublaboratorios')); ?>/" + this.value);
                                            console.log(this.value);
                                        });

                                        $('#btNuevoLaboratorio').click(function() {
                                            $('#muestraNuevoLaboratorio').toggle('slow');
                                        });
                                    });
                                </script>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <span class="clear"></span>

        <div class="grid_12">
            <div class="widget_wrap">
                <div class="widget_top">
                    <span class="h_icon blocks_images"></span>
                    <h6>Acciones</h6>
                </div>
                <div class="widget_content">
                    <div class="all_buttons">
                        <div class="btn_40_blue ucase">
                            <a href="#"><span class="icon finished_work_sl"></span><span>NUEVA MEDICION &nbsp;&nbsp;&nbsp; </span></a>
                        </div>

                        <div class="btn_40_blue ucase">
                            <a href="#"><span class="icon finished_work_sl"></span><span>NUEVO LABORATORIO &nbsp;&nbsp;&nbsp; </span></a>
                        </div>

                        <div class="btn_40_blue ucase">
                            <a href="#"><span class="icon finished_work_sl"></span><span>NUEVA MEDICION &nbsp;&nbsp;&nbsp; </span></a>
                        </div>

                        <div class="btn_40_blue ucase">
                            <a href="#"><span class="icon finished_work_sl"></span><span>NUEVA MEDICION &nbsp;&nbsp;&nbsp; </span></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>